// DivideTwoIntegers.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
//Divide two integers without using multiplication, division and mod operator

class Solution {
public:
    int divide(int dividend, int divisor) {
        // Start typing your C/C++ solution below
        // DO NOT write int main() function

        if(dividend == 0 || divisor == 0) return 0;
        bool bNeginative = false;
        if(dividend < 0) 
        {
            bNeginative = true;
            dividend = 0 - dividend;
        }
		if(divisor <0)
		{
			bNeginative = true;
			divisor = 0-divisor;
		}
        int ret = 0;
		int Left = dividend;
		while(Left>=divisor)
        {
            ret+=1;
            
            Left-=divisor;
        }

        if(bNeginative)
         ret = 0-ret;
        return ret;
    }
};
int _tmain(int argc, _TCHAR* argv[])
{
	Solution S;
	S.divide(1, -1);
	return 0;
}

